'use strict';

var _interopRequireWildcard = require('@babel/runtime/helpers/interopRequireWildcard');
var _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');
Object.defineProperty(exports, '__esModule', {
  value: true,
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require('@babel/runtime/helpers/objectSpread2'));
var _react = _interopRequireWildcard(require('react'));
var _FieldContext = require('../../contexts/FieldContext');
require('./index.css');
var List = function List(_ref) {
  var value = _ref.value,
    renderItemDetail = _ref.renderItemDetail,
    children = _ref.children;
  var _useFieldContext = (0, _FieldContext.useFieldContext)(),
    name = _useFieldContext.name;
  return /*#__PURE__*/ _react.default.createElement(
    'div',
    {
      className: 'szzj-form-detail-list',
    },
    (value || []).map(function (item, index) {
      return /*#__PURE__*/ _react.default.createElement(
        'div',
        {
          className: 'szzj-form-detail-item',
          key: index,
        },
        renderItemDetail
          ? renderItemDetail(item, index)
          : /*#__PURE__*/ _react.default.createElement(
              'div',
              {
                className: 'szzj-form-detail-row',
                key: index,
              },
              _react.Children.map(children, function (child) {
                var props = child.props;
                return /*#__PURE__*/ (0, _react.cloneElement)(
                  child,
                  (0, _objectSpread2.default)(
                    (0, _objectSpread2.default)({}, props),
                    {},
                    {
                      name: [name, index, props.name],
                      key: ''.concat(index).concat(props.name),
                    },
                  ),
                );
              }),
            ),
      );
    }),
  );
};
var _default = List;
exports.default = _default;
